package jmind.core.serialize;

import com.alibaba.fastjson.JSON;

import java.io.IOException;

/**
 * description:
 *
 * @author weibo.xie
 * @date : create in 8:35 下午 2021/5/13
 */
public class JSONSerializer extends ActualType  implements  Serializer {


    public JSONSerializer(Class type) {
        super(type);
    }

    @Override
    public byte[] serialize(Object object) throws IOException {
        return JSON.toJSONString(object).getBytes();
    }

    @Override
    public Object deserialize(byte[] bytes) throws IOException {
        Class type = getType();
        return JSON.parseObject(bytes,type);
    }



}